<template>
<div>
  <!-- 使用单一分栏创建基础的栅格布局  -->
  <!-- 通过 row 和 col 组件，并通过 col 组件的 span 属性我们就可以自由地组合布局 -->
  <h2>基础布局</h2>
  <el-row>
    <!-- span 栅格占据的列数 number类型 默认值24 -->
  <el-col :span="24"><div class="grid-content bg-purple-dark"></div></el-col>
</el-row>
<el-row>
  <!-- span一行一共24,12表示分成两半 -->
  <el-col :span="12"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="12"><div class="grid-content bg-purple-light"></div></el-col>
</el-row>
<el-row>
  <el-col :span="8"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="8"><div class="grid-content bg-purple-light"></div></el-col>
  <el-col :span="8"><div class="grid-content bg-purple"></div></el-col>
</el-row>
<el-row>
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple-light"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple-light"></div></el-col>
</el-row>
<el-row>
  <el-col :span="4"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="4"><div class="grid-content bg-purple-light"></div></el-col>
  <el-col :span="4"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="4"><div class="grid-content bg-purple-light"></div></el-col>
  <el-col :span="4"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="4"><div class="grid-content bg-purple-light"></div></el-col>
</el-row>
<br>
<br>
<h2>分栏间隔</h2>
<!-- 分栏之间存在间隔，Row 组件 提供 gutter 属性来指定每一栏之间的间隔，默认间隔为 0 -->
<el-row :gutter="20">
  <!-- gutter 栅栏间隔 number类型 默认值是0 -->
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
</el-row>
<br>
<br>
<h2>混合布局</h2>
<!-- 通过基础的 1/24 分栏任意扩展组合形成较为复杂的混合布局 -->
<el-row :gutter="20">
  <el-col :span="16"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="8"><div class="grid-content bg-purple"></div></el-col>
</el-row>
<el-row :gutter="20">
  <el-col :span="8"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="8"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="4"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="4"><div class="grid-content bg-purple"></div></el-col>
</el-row>
<el-row :gutter="20">
  <el-col :span="4"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="16"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="4"><div class="grid-content bg-purple"></div></el-col>
</el-row>
<br>
<br>
<h2>分栏偏移</h2>
<!-- 支持偏移指定的栏数，通过制定 col 组件的 offset 属性可以指定分栏偏移的栏数 -->
<el-row :gutter="20">
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
  <!-- offset 栅格左侧的间隔格数 number类型 默认值0 -->
  <el-col :span="6" :offset="6"><div class="grid-content bg-purple"></div></el-col>
</el-row>
<el-row :gutter="20">
  <el-col :span="6" :offset="6"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="6" :offset="6"><div class="grid-content bg-purple"></div></el-col>
</el-row>
<el-row :gutter="20">
  <!-- pull 栅格向左移动格数 number类型 默认值0 -->
  <el-col :span="6" :pull="6"><div class="grid-content bg-purple"></div></el-col>
</el-row>
<el-row :gutter="20">
  <!-- push 栅格向右移动格数 number 类型 默认值0 -->
  <el-col :span="12" :push="6"><div class="grid-content bg-purple"></div></el-col>
</el-row>
<br>
<br>
<h2>对齐方式</h2>
<!-- 通过 flex 布局来对分栏进行灵活的对齐 -->
<!-- 将 type 属性赋值为 'flex'，可以启用 flex 布局，并可通过 justify 属性来指定 start, center, end, space-between, space-around 其中的值来定义子元素的排版方式 -->
<el-row type="flex" class="row-bg">
  <!-- type 布局模式可选flex 现代浏览器有效 string 类型 -->
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple-light"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
</el-row>
<h3>justify="center"</h3>
<el-row type="flex" class="row-bg" justify="center">
  <!--justify flex 布局下的水平排列方式  string 类型 可选值start/end/center/space-around/space-between 默认值start  -->
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple-light"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
</el-row>
<h3>justify="end"</h3>
<el-row type="flex" class="row-bg" justify="end">
  <!--justify flex 布局下的水平排列方式  string 类型 可选值start/end/center/space-around/space-between 默认值start  -->
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple-light"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
</el-row>
<h3>justify="space-around"</h3>
<el-row type="flex" class="row-bg" justify="space-around">
  <!--justify flex 布局下的水平排列方式  string 类型 可选值start/end/center/space-around/space-between 默认值start  -->
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple-light"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
</el-row>
<h3>justify="space-between"</h3>
<el-row type="flex" class="row-bg" justify="space-between">
  <!--justify flex 布局下的水平排列方式  string 类型 可选值start/end/center/space-around/space-between 默认值start  -->
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple-light"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
</el-row>

<!-- tag 自定义元素标签 string 类型 可选值* 默认值div -->
<el-row type="flex" class="row-bg" justify="end" tag="div">
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple-light"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
</el-row>
<el-row type="flex" class="row-bg" justify="space-between">
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple-light"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
</el-row>
<el-row type="flex" class="row-bg" justify="space-around">
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple-light"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
</el-row>
<!-- align flex 布局下的垂直排列方式 string类型 可选值：top/middle/bottom 默认值top -->
<h3> align="middle"</h3>
<el-row type="flex" class="row-bg" justify="space-around" align="middle">
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple-light"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
</el-row>
<br>
<br>
<h3>align="bottom"</h3>
<el-row type="flex" class="row-bg" justify="space-around" align="bottom">
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple-light"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
</el-row>
<br>
<br>
<h3>align="top"</h3>
<el-row type="flex" class="row-bg" justify="space-around" align="top">
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple-light"></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
</el-row>
<h2>响应式布局</h2>
<!-- 参照了 Bootstrap 的 响应式设计，预设了五个响应尺寸：xs、sm、md、lg 和 xl -->
<el-row :gutter="10">
  <!-- xs <768px 响应式栅格数或者栅格属性对象 number/object类型 -->
  <el-col :xs="8" :sm="6" :md="4" :lg="3" :xl="1"><div class="grid-content bg-purple"></div></el-col>
  <!-- sm  ≥768px 响应式栅格数或者栅格属性对象 number/object类型 -->
  <el-col :xs="4" :sm="6" :md="8" :lg="9" :xl="11"><div class="grid-content bg-purple-light"></div></el-col>
  <!-- md ≥992px 响应式栅格数或者栅格属性对象 number/object类型 -->
  <el-col :xs="4" :sm="6" :md="8" :lg="9" :xl="11"><div class="grid-content bg-purple"></div></el-col>
  <!-- lg ≥1200px 响应式栅格数或者栅格属性对象  number/object类型 -->
  <el-col :xs="8" :sm="6" :md="4" :lg="3" :xl="1"><div class="grid-content bg-purple-light"></div></el-col>
  <!-- xl ≥1920px 响应式栅格数或者栅格属性对象  number/object类型 -->
</el-row>

</div>
</template>

<script lang="ts">
import Vue from 'vue';

export default class Layout extends Vue {}
</script>

<style scoped lang="less">
.el-row {
    margin-bottom: 20px;
    &:last-child {
      margin-bottom: 0;
    }
  }
  .el-col {
    border-radius: 4px;
  }
  .bg-purple-dark {
    background: #99a9bf;
  }
  .bg-purple {
    background: #d3dce6;
  }
  .bg-purple-light {
    background: #e5e9f2;
  }
  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }
  .row-bg {
    padding: 10px 0;
    background-color: #f9fafc;
  }
</style>
